package songhq.crypto;

import java.security.MessageDigest;
import java.util.Base64;

/**
 * hash算法的
 */
public class ShaUtil {


    public static String sha(String dataStr){
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
            messageDigest.update(dataStr.getBytes("UTF-8"));
            byte[] digest = messageDigest.digest();
            return Base64.getEncoder().encodeToString(digest);
        }catch (Exception e){
            System.out.println("");
        }
        return null;
    }

    public static void main(String[] args) {
        String str = sha("你好");
        System.out.println(str);

    }
}
